﻿using System.Dynamic;
using Basic.FormGatewaryModular.Interface;
using Basic.FormGatewaryModular.Model.QueryForm;
using Basic.FormRemoteModel.QueryForm;
using Basic.FormRemoteModel.QueryForm.Model;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Services
{
    internal class QueryFormService : IQueryFormService
    {
        public PagingResult<ExpandoObject> Query ( PagingParam<QueryTableArg> param, long comId )
        {
            return new QueryPhyTable
            {
                Index = param.Index,
                Size = param.Size,
                SortName = param.SortName,
                IsDesc = param.IsDesc,
                NextId = param.NextId,
                QueryParam = new QueryTableParam
                {
                    CompanyId = comId,
                    FormId = param.Query.FormId,
                    QueryParam = param.Query.QueryParam
                }
            }.Send();
        }
        public QueryFormBody GetBody ( long formId )
        {
            return new GetQueryFormBody
            {
                Id = formId,
            }.Send();
        }
        public QueryFormRecord GetRecord ( long formId, long id )
        {
            return new GetQueryFormRecord
            {
                FormId = formId,
                Id = id
            }.Send();
        }
    }
}
